{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "a759cf2f",
   "metadata": {},
   "outputs": [],
   "source": [
    "class Student(object):\n",
    "    company = \"尚学堂\"\n",
    "    count = 0\n",
    "    def __init__(self,temp_name,temp_age):\n",
    "        self.name = temp_name\n",
    "        self.age = temp_age\n",
    "        Student.count +=1\n",
    "    \n",
    "    def change_age(self,new_age):\n",
    "        self.age = new_age\n",
    "    \n",
    "    def __call__(self,a):\n",
    "        if self.age+a>23:\n",
    "            return False\n",
    "        else:\n",
    "            return True\n",
    "    \n",
    "    def __add__(self,other):\n",
    "        return self.age+other.age"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "61fb2c51",
   "metadata": {},
   "outputs": [],
   "source": [
    "s1 = Student(\"张三\",18)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "86b1a142",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<__main__.Student object at 0x0000015DC3712BC8>\n"
     ]
    }
   ],
   "source": [
    "print(s1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "b54a7144",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "21\n"
     ]
    }
   ],
   "source": [
    "s1.change_age(21)\n",
    "print(s1.age)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "9ee726ce",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "尚学堂\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "print(Student.company)\n",
    "print(Student.count)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "7dd4ad06",
   "metadata": {},
   "outputs": [],
   "source": [
    "s2=Student(\"asd\",23)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "1c8b6cec",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2\n"
     ]
    }
   ],
   "source": [
    "print(Student.count)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "bda67d97",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9ca941b5",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "my_test",
   "language": "python",
   "name": "my_test"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
